package sample.controller.category;

import java.util.logging.Logger;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;
import org.slim3.datastore.Datastore;
import org.slim3.util.BeanUtil;
import org.slim3.util.StringUtil;

import sample.controller.model.Category;

public class AddController extends Controller {

    @SuppressWarnings("unused")
    private static final Logger logger = Logger.getLogger(AddController.class.getName());

    @Override
    public Navigation run() {
        String name = asString("name");
        if (!StringUtil.isEmpty(name)) {
            Category c = new Category();
            c.setName(asString("name"));
            
            Datastore.put(c);
            
            BeanUtil.copy(c, request);
        }
        return forward("add.jsp");
    }
}
